package com.trkj.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.trkj.dao.jpa.IHpatientRegDao;
import com.trkj.dao.mybatis.HpatientRegMapper;
import com.trkj.pojos.Business;
import com.trkj.pojos.HospPatientRegistration;

@Service
@Transactional
public class PatientRegistrationService {
	@Autowired
	private HpatientRegMapper hpatientMapper;
	@Autowired
	private IHpatientRegDao hpatientRegDao;
	
	public Map<String,Object> findOneDoctorRegistration(int page,int rows,String doctorID){		
		Page<Map> p = PageHelper.startPage(page, rows, true);
		List<Map> list = hpatientMapper.findOneDoctorRegistration(doctorID);
		Map<String,Object> map = new HashMap<>();
		map.put("total", p.getTotal());
		map.put("rows", list);
		return map;
		
	}

	public boolean updateRegistration(String patient_reg_id) {
		try {
			HospPatientRegistration findOne = hpatientRegDao.findOne(patient_reg_id);		
			findOne.setStatus("正在接诊");
			hpatientRegDao.save(findOne);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		
	}

}
